<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2022-12-23 10:27:23
 * @Last Modified time: 2022-12-23 16:34:22
 */
namespace app\common\dao\store;

use frank\base\BaseDao;
use app\common\model\store\GoodsSpecTemplatesModel;

/**
 * Class GoodsSpecTemplatesDao
 * @package app\common\dao\store
 */
class GoodsSpecTemplatesDao extends BaseDao
{
    /**
     * 设置模型名
     */
    protected function setModel(): string
    {
        return GoodsSpecTemplatesModel::class;
    }

    /**
     * 列表
     */
    public function getGoodsSpecTemplatesList(array $where = [], int $page, int $limit)
    {
        return $this->search($where)->order('id DESC')->page($page)->paginate($limit)->toArray();
    }
    
    /**
     * 获取全部
     */
    public function getGoodsSpecTemplatesSelect(array $searchWhere = [], array $field = ['*'], array $where = [])
    {
        return $this->search($searchWhere)->when(count($where), function ($query) use ($where) {
            $query->where($where);
        })->field($field)->order('id DESC')->select()->toArray();
    }
}
